%%% License: Creative Commons Attribution Share Alike 4.0 (see https://creativecommons.org/licenses/by-sa/4.0/)
%%% Slides are based heavily on earlier versions of this course taught by Jesper Rudiger.

\documentclass[english,10pt
%,handout
,aspectratio=169
]{beamer}
\input{../FM_preamble.tex}



\title{Financial Markets Microstructure \\ Lecture 6}

\subtitle{Limit order book\\
	Chapter 6.1-6.2 of FPR}

\author{Egor Starkov}

\date{K{\o}benhavns Unversitet \\
	Spring 2020}




\begin{document}
\AtBeginSection[]{
\frame<beamer>{
\frametitle{This lecture:}
\tableofcontents[currentsection,currentsubsection]
}}
\frame[plain]{\titlepage}

%\section{Revision and readings}

\begin{frame}{Last time}
	\begin{itemize}
		\item The Kyle model helps us analyze market depth:
		\begin{itemize}
			\item Hence, it tells us something about how adverse selection causes spread to vary with trade size
			\item The model has batch clearing instead of the single-unit market of GM
		\end{itemize}
		\item We can use insights from theory to estimate the importance of different components of the spread
		\begin{itemize}
			\item Perhaps surprisingly, order costs are by far the largest cost (but estimated on major stocks)
			\item Around 19\% of trading is informed
			\item Adverse selection is stronger for less liquid/small-cap stocks
		\end{itemize}
	\end{itemize}
\end{frame}


%\begin{frame}{Exercise}
%	% the conclusions from last time may lead us into thinking that informed trading is no big deal. These articles aim to argue the converse
%	\begin{itemize}
%		\item I uploaded two articles from the Economist, March 7, 2014, both on potential manipulation of prices
%		\item Consider these two issues:
%		\begin{itemize}
%			\item What motivates a trader to manipulate an asset's price? 
%			\item Is manipulation easier in a very liquid or a very illiquid market?
%			% less liquid requires less effort to manipulate the price, but it looks less credible
%		\end{itemize}
%	\end{itemize}
%\end{frame}



\section{LOB Markets}

\begin{frame}{Introduction}
	\begin{itemize}
		\item There's a reason that first models of financial markets (GM and Kyle) explored dealer markets...
	\end{itemize}
\end{frame}


\begin{frame}
	\centering
	\includegraphics[scale=0.5]{pics/mkt20}
	
	Financial market in 1985
\end{frame}


\begin{frame}
	\centering
	\includegraphics[scale=0.19]{pics/mkt21}
	
	Financial market today
\end{frame}


\begin{frame}{Introduction}
	\begin{itemize}
		\item Most markets are order-driven these days
		\begin{itemize}
			\item Some exchanges combine LOBs and dealers
		\end{itemize}
		\item How do \alert{LOB markets} differ from pure \alert{dealer markets}?
		\begin{itemize}
			\item Not much changes for those who submit market orders
			\item Limit traders are like dealers, face adverse selection risk, but now also \structure{non-execution risk}
			% the two latter risks can represent the fundamentals moving in two different direction
		\end{itemize}
		\item \structure{No exogenous separation} between liquidity providers and demanders in LOB mkts -- any trader can choose between limit and market orders
		\begin{itemize}
			\item Limit traders can get better prices compared to market orders, but at the cost of delay
			\item Self-balancing mechanism (e.g., thin LOB -- market orders are costly while limit orders are exec-d quickly -- high incentives to submit limit order)
		\end{itemize}
	\end{itemize}
\end{frame}


%\begin{frame}{Introduction}
%	\begin{itemize}
%		\item \structure{Price discrimination}:  LOB has discriminatory pricing of larger orders
%		\begin{itemize}
%			\item Difference to Kyle's (auction) model: in LOB, total order size is not observed, you only know that your limit order has been `hit'
%			\item \cite{glosten_is_1994} provides a Glosten-Milgrom style model of the price schedule offered (i.e., how much volume supplied at the limit prices)
%		\end{itemize}
%		\item \structure{Ticks}: Often prices are discrete and must lie at a tick (e.g. at NYSE, ticks are multiples of 1 cent) --  tick size is the increment btw prices:
%		\begin{itemize}
%			\item Prioritized limit orders become profitable when there are ticks 
%			(since no `marginal undercutting')
%			\item We will analyze the effects of changing ticks, priority rules
%		\end{itemize}
%		\item \structure{Interpretation}: One way of thinking of an LOB is that dealers post limit orders, as in the GM model
%	\end{itemize}
%\end{frame}



\section{Static Analysis: Glosten Model}

\begin{frame}{\cite{glosten_is_1994} model}
	\begin{itemize}
		\item (Probably) first model of LOB markets
		\item Questions simple:
		\begin{itemize}
			\item What drives the prices? Are they efficient?
			\item How is LOB depth determined?
		\end{itemize}
	\end{itemize}
\end{frame}


\begin{frame}{Continuous model: Limit order book}
\begin{itemize}
	\item \textbf{Single asset}: Unknown value $v$ with cumulative distribution  $G(v)$
	\item \textbf{Limit order book} (composed by competitive limit traders): 
	\begin{itemize}
		\item Focus on the ask side of the market (limit orders to sell vs market order to buy)
		\item Prices vary with volume $q$. Posted limit orders: $P'(q)$
		\item A market buy order of size $q$ will `walk up the book' until the final bit of it is cleared at a limit price $P'(q)$
		\item The entire payment for buying volume $q$ is then
		\[
		P(q) = \int_0^q P'(\tilde{q}) \, d\tilde{q}.
		\]
		\item The average price is 
		\[
		p(q) = \frac{P(q)}{q}.
		\]
	\end{itemize}
\end{itemize}
\end{frame}


\begin{frame}{Continuous model: Marginal rate of substitution}
	\begin{itemize}
		\item \textbf{Single market trader} $i$ per period (as in GM/Kyle)
		\item $\theta_i(q)$ is trader $i$'s marginal rate of substitution (marginal valuation for $q$th unit of the asset)
		\item If an incoming trader $i$ chooses a market buy order $q$ and parts with cash $P(q)$, we should have: \[\theta_i(q) = P'(q).\]
		\item If incoming traders are to some extent informed, it's reasonable to suppose that for a given $q$, higher $\theta_i(q)$ indicates higher asset value $v$
		\item Thus, we assume that 
		\[
		\mathbb{E}[v|\theta_i(q) = \theta]
		\]
		is strictly increasing in $\theta$
	\end{itemize}
\end{frame}


\begin{frame}{Continuous model: Market makers}
	\begin{itemize}	
		\item \textbf{Limit traders} are competitive, post limit orders
		\item Limit price $P'(q)$ quoted for the $q$-th unit is relevant only if the trader places a market order of $q$ or larger, i.e. $\theta_i(q) \geq P'(q)$
		\item Hence, if supply is competitive then
		\[
		\structure{P'(q) = \mathbb{E}[v|\theta_i(q) \geq P'(q)]}
		\]
		%\item Notice that all we know if limit price $P'(q)$ is `hit' is that the trader's marginal valuation was \textit{at least} $P'(q)$
	\end{itemize}
\end{frame}


\begin{frame}{Continuous model: Equilibrium}
	Adverse selection implies
	\begin{align}
	P'(q) = \mathbb{E}[v|\theta_i(q) \geq P'(q)] > \mathbb{E}[v|\theta_i(q) = P'(q)]
	\end{align}
	\begin{block}{Implications}
		\begin{itemize}
			\item Thus, market makers (ex post) profit on the sale of the last units
			\item At small realized trades, $q \simeq 0$, MM always profit
			\item Even with continuous prices, there is a non-zero \structure{inside spread} between ask and bid prices as the order size goes to zero (contrast with Kyle)
			% The reason is that in the limit order market, liquidity suppliers cannot make their quotes contingent on the total size of market orders. As a result, the limit orders at the top of the book are more exposed to adverse selection.
			\item After a trade of size $q$, new expected asset value is below $P'(q)$. \pause 
			
			\structure{New expected value = $\mathbb{E}[v|\theta_i(q)=P'(q)]<\mathbb{E}[v|\theta_i(q) \ge P'(q)]=P'(q)$}. Often new limit orders will be posted below $P'(q)$ -- price reversal.
		\end{itemize}
	\end{block}
\end{frame}


\begin{frame}{Intermission}
	\begin{itemize}
		\item The general model above outlines some basic differences between LOB and dealer markets
		\begin{itemize}
			\item Adverse selection affects prices differently
		\end{itemize}
		\item It neglects the \structure{discreteness of prices}:
		\begin{itemize}
			\item Often prices are discrete and must lie at a tick --  tick size is the increment b/w prices
			\item E.g. at NYSE it was \$1/8 for stocks with prices over one dollar until June 1997, when, under regulatory pressure, it was reduced to \$1/16 and finally, in 2000, to one cent.
			\item Prioritized limit orders become profitable when there are ticks (since no `marginal undercutting')
		\end{itemize}
	\end{itemize}
\end{frame}


\begin{frame}{Discrete model: Setup}
	\begin{itemize}
		\item \textbf{Asset}: Continue with single asset with value $v \sim G$
		\item \textbf{Market order $q$}
		\begin{itemize}
			\item Cumulative distribution function $F(q)$
			\item Again, focus on the ask side of the book, $q>0$
		\end{itemize}
		\item \textbf{Discrete price grid}
		\begin{itemize}
			\item $A_1$ is lowest price tick above $\mu$
			\item $A_k-A_{k-1}>0$ is the tick size
		\end{itemize}
		\item \textbf{Limit orders}
		\begin{itemize}
			\item \textit{Time prioritized}: first posted, first executed
			\item \textit{Display cost}: $C$ per unit (paid regardless of whether order executes)
			% This display cost is here for the model to work even without adverse selection
			\item Let $y_k$ denote the amount supplied at price $A_k$
			\item Let $Y_k=\sum_{j=1}^k y_j$ be cumulative volume (depth) supplied at or below $A_k$
			% Y_k(A_k) is the inverse of P(q)
		\end{itemize}
	\end{itemize}
\end{frame}


\begin{frame}{Discrete model: Equilibrium}
	%Let $\mathbb{E}[v|q \geq Y_k]=\mathbb{E}[v|\theta_i(q) \geq P'(q)]$.
	Let $\mathbb{E}[v|q \geq Y_k]=\mathbb{E}[v|\theta_i(q) \geq A_k]$.
	\begin{itemize}
		\item \textbf{Competition}: Limit orders are supplied at each tick until the \structure{last order earns zero profit}
		\item \textbf{Zero-profit condition}:
		\[
		\mathbb{P}(q \geq Y_k)[A_k-\mathbb{E}[v|q \geq Y_k]] - C = 0,
		\]
		solved by
		\begin{block}{}
			\[
			A_k = \underbrace{\mathbb{E}[v| q \geq Y_k]}_{\text{\alert{Adverse selection}}} + \underbrace{\frac{C}{\mathbb{P}(q\geq Y_k)}}_{\text{\alert{Execution risk}}}
			\]
		\end{block}
		(we need to solve for $Y_k$ given $A_k$)
		%\item \textbf{Adverse selection}: Captured by  $\mathbb{E}[v| q \geq Y_k] $
		%\begin{itemize}
		%	\item Unlike most of what we had before, this model works even without adverse selection
		%\end{itemize}
	\end{itemize}
\end{frame}


\begin{frame}{Example 1: Model} 
	\begin{itemize}
		\item \textbf{Asset}. Let $g$ be the marginal distribution of $G$ and
		\[
		g(v)=\left\{ \begin{aligned}
		1/2  & \text{ if } v=v^H; \\
		1/2 & \text{ if } v=v^L,
		\end{aligned}
		\right.
		\]
		with $v^{H}=\mu + \sigma $ and $v^{L}= \mu - \sigma $.
		\item \textbf{Traders}. Single trader, who uses a market order.
		\begin{itemize}
			\item Prob. $\pi$: risk-neutral speculator (\structure{S}) who knows $v$
			\item Prob $1-\pi$: noise trader (\structure{N})  who buys/sells with equal probability, and uses large ($q_L$) or small ($q_S<q_L$) order with equal probability:
			$$
			\mathbb{P}(q=q_S|\structure{N})= \mathbb{P}(q=q_L|\structure{N})=\mathbb{P}(q=-q_S|\structure{N})=\mathbb{P}(q=-q_L|\structure{N})=1/4
			$$
		\end{itemize}
		\item \textbf{No display cost}. Let $C=0$
		\item \textbf{Continuous prices}.
	\end{itemize}
\end{frame}


\begin{frame}{Example 1: Equilibrium}
	\begin{itemize}
		\item \textbf{Separating equilibrium}: Look for eq. with $y_{1}=q_{S}$ and $y_{2}=q_{L}-q_{S}$ for some ask prices $v^L<A_1<A_2<v^H$ (hence $Y_1=q_S$ and $Y_2=q_L$)
		\item \textbf{Speculator}: 
		\begin{itemize}
			\item If $q \notin \{q_S,q_L\}$, speculator reveals himself
			\item 
			When observing $v=v^{H}$ speculator buys $q_{L}$ units, when $v=v^L$ don't buy (maybe sell)
		\end{itemize}
		\item \textbf{Price}. In equilibrium, price equals expected value given $q$. Hence,
		\begin{block}{}
			\[\begin{aligned}
			A_1 & =\mathbb{E}[v|q \geq q_{S}] = \mu + \pi \sigma,\\
			A_2 & = \mathbb{E}[v|q \geq q_{L}] = \mu + \frac{2\pi}{1+\pi} \sigma
			\end{aligned}
			\]
		\end{block}
		\item Straightforward that $v^L<A_1<A_2<v^H$. Thus: equilibrium.
		%TODO: need to verify optimality of qL for S -- holds only if qS < qL / (1+pi)
	\end{itemize}
\end{frame}


\begin{frame}{Example 1: Comment}
	\begin{itemize}
		\item Bad example for discreteness:
		\begin{itemize}
			\item The example does \emph{not} assume fixed ticks...
			\item But they arise endogenously in equilibrium...
			\item Due to discreteness of noise traders' strategy
			\item (A very artificial assumption)
		\end{itemize}
		\item Focus on adverse selection:
		\begin{itemize}
			\item Price increases in order size
			\item Not due to informed trader having stronger info, as in Kyle model
			\item But due to noise traders' order becoming less likely
		\end{itemize}
	\end{itemize}
\end{frame}


\begin{frame}{Example 2: Model}
	\begin{itemize}
		\item \textbf{Market orders}: Exponential distribution, $f(q)=\frac{\theta}{2} e^{-\theta|q|}$
		\item \textbf{Asset}. Assume `price impact' equation $\mathbb{E}[v|q=x] = \mu + \lambda x$ where $\lambda >0$ is a constant measuring informativeness of order flow
		\item Thus, we are taking a short-cut and modeling adverse selection in a `reduced form': rather than modeling the informed traders, we model their price impact
	\end{itemize}
\end{frame}


\begin{frame}{Example 2: Equilibrium}
	\begin{itemize}
		\item Focus on  \textbf{ask side}: $Y_k>0$. For $q \geq Y_{k}$:
		\begin{align*}
		f(q|q \ge Y_k)&=\frac{f(q)}{ \mathbb{P}(q \geq Y_{k})} \\
		&= \frac{f(q)}{\int^\infty_{Y_k} f(q) dq}\\
		&= \frac{\frac{\theta}{2} \cdot e^{-\theta q}}{e^{-\theta Y_{k}}/2} \quad \quad \text{ ($|q|=q$ since $q \ge Y_k>0$)}\\
		& =\theta \cdot e^{-\theta(q-Y_{k})}\\
		& = e^{Y_k} \left[ \theta \cdot e^{-\theta q} \right]
		\end{align*}
	\end{itemize}
\end{frame}


\begin{frame}{Example 2: Equilibrium (2)}
	\begin{itemize}
		\item The expected value at tick $k$ becomes
		\begin{align*}
		\mathbb{E}[v|q \geq Y_{k}] & =  \mu + \lambda \mathbb{E}[q|q \geq Y_{k}]\\
		&=\mu+ \lambda \int^\infty_{Y_k} q \cdot f(q|q \geq Y_{k}) dq\\
		&=\mu+ \lambda e^{\theta Y_{k}} \int^\infty_{Y_k} q \cdot \theta \cdot e^{-\theta q} dq\\
		& =  \mu+ \lambda e^{\theta Y_{k}} \left\{\left[- q \cdot e^{-\theta q} \right]^\infty_{Y_k} -\int^\infty_{Y_k} -e^{-\theta q} dq   \right\}\text{ (int. by parts)} \\
		& =  \mu+ \lambda e^{\theta Y_{k}} \left\{\left[0+ Y_k \cdot  e^{-\theta Y_k} \right] -\frac{1}{\theta}[0-e^{-\theta Y_k}]   \right\} \\
		& = \mu + \lambda \left( \frac{1}{\theta }+ Y_{k} \right)
		\end{align*}
	\end{itemize}
\end{frame}


\begin{frame}{Example 2: Equilibrium (3)}
	\begin{itemize}
		\item Hence, the ask price at tick $k$ can be found by solving
		\[
		\underbrace{\structure{\mathbb{P}(q \geq Y_k)}}_{e^{-\theta Y_{k}}/2}[A_k-\underbrace{\structure{\mathbb{E}[v|q \geq Y_k]}}_{\mu + \lambda \left( \frac{1}{\theta }+ Y_{k} \right)}] - C = 0,
		\]
		which gives
		\begin{block}{}
			\[
			A_k=\mu + \lambda \left( \frac{1}{\theta }+ Y_{k}\right) + \frac{2C}{e^{-\theta Y_{k}}}.
			\]
		\end{block}
		\item (We actually need the opposite -- find $Y_k$ for a given tick $A_k$.)
	\end{itemize}
\end{frame}



%\section{Market design}
%
%\begin{frame}{Market design}
%	\begin{itemize}
%		\item Now let us turn to the issue of \alert{market design}
%		\item There was not much scope for design in dealer markets, but in LOB markets the platform can influence a few important aspects of the market, such as:
%		\begin{itemize}
%			\item tick size
%			\item priority rules
%			\item putting a dealer in there
%		\end{itemize}
%		\item These all have non-trivial repercussions for limit traders' behavior
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Tick size}
%	\begin{itemize}
%		\item Assume \structure{time priority} is the second order after price priority
%		\begin{itemize}
%			\item I.e., first limit order posted at tick executes first
%		\end{itemize}
%		\item Profit of the limit trader at price $A_k$ is:
%		\begin{itemize}
%			\item Zero for the marginal (last) limit order at $A_k$
%			\item Strictly positive for inframarginal orders (if $C>0$) because order executes with higher probability
%		\end{itemize}
%		\item This profit is reduced with \alert{smaller tick sizes}
%		\begin{itemize}
%			\item Hence decreasing tick size drives away limit traders and reduces depth
%			\item But it will also reduce spread (by design) and reduce trading costs for the opposite side of the market (liquidity demanders)
%		\end{itemize}
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Tick size}
%	\begin{itemize}
%		\item Driving away limit traders intuitively also has dynamic repercussions
%		\begin{itemize}
%			\item LOB is replenished more slowly after trades -- so market orders traded more frequently against non-competitive prices
%		\end{itemize}
%		\item \cite{goldstein_eighths_2000} explored the NYSE 1997 case (tick size from $\$1/8$ to $\$1/16$)
%		\begin{itemize}
%			\item Trading costs decreased for small orders
%			\item Unclear for large orders
%			\item Aligns with our predictions (smaller spread, smaller depth)
%		\end{itemize}
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Priority rules}
%	\begin{itemize}
%		\item With \structure{pro-rata} allocation (limit orders at given tick executed proportionally to their size), as opposed to \alert{time priority}:
%		\begin{itemize}
%			\item The expected profit of all orders at price $A_k$ must be zero (as opposed to strictly positive)
%			\item So execution probabilities must be lower for all orders
%			\item Meaning more orders are posted under pro-rata.
%			% not sure about this last part
%		\end{itemize}
%		\item Lower profits lead to same dynamic consequences as with reducing tick size
%		\item Pro-rata allocation rule used in the electronic futures markets for the leading short-term interest rate and for the two-year U.S. Treasuries.
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Hybrid market}
%	Hybrid market
%	\begin{itemize}
%		\item Suppose a dealer can compete with the limit order book, as follows
%		\item The dealer may observe the size $q$ before serving the order (last-mover advantage)
%		\item Can profit by pricing at $\mathbb{E}[v|q=x]$ rather than an average of $\mathbb{E}[v|q \geq y]$ for $y \leq x$ which is used by the LOB
%		\item Especially profitable on small trades
%		\item But the existence of such a dealer invalidates our analysis of the LOB
%		\item Profitable limit orders are being picked off
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Hybrid market: Example}
%	\begin{itemize}
%		\item Example 1 continued. Assume an uninformed dealer receives order $q$. Can either send order to LOB or execute himself (at better price) 
%		\item Focus on ask side. Let $A^H_k$ be the hybrid ask price. When dealer observes $q=q_S$, he knows trader is noise trader and thus $\mathbb{E}[v|\structure{N}]=\mu$. 
%		\begin{itemize}
%			\item Can execute order at just below $A^H_1$ and earn profit $A^H_1-\mu$.
%		\end{itemize}
%		\item Hence, only large orders $q=q_L$ are sent to LOB. LOB traders will expect this, and will price as if any order arriving to the LOB is large:
%		\begin{align*}
%		\mathbb{E}[v|q \ge q_S]=\mathbb{E}[v|q \ge q_L]=\mu+\frac{2\pi}{1+\pi} \sigma,
%		\end{align*}
%		and thus $A^H_1=A^H_2=\mu+\frac{2\pi}{1+\pi} \sigma$.
%		\item $A^H_1>A_1$ and $A^H_2=A_2$: hybrid market less liquid than normal market
%	\end{itemize}
%\end{frame}


%\begin{frame}{\cite{glosten_is_1994}: Conclusion}
%	\begin{itemize}
%		\item Ordinary traders can  use limit orders to compete with market makers
%		\begin{itemize}
%			\item Our model of market orders?
%		\end{itemize}
%		\item Limit order book is actually dynamic
%		\begin{itemize}
%			\item Consequences of priority rules?
%		\end{itemize}
%	\end{itemize}
%	Glosten argued that if orders can be freely split between competing trading platforms (which need not have limit order books), then the aggregate pricing schedule must be that from the competitive order market
%\end{frame}


\begin{frame}{Conclusion}
	\begin{itemize}
		\item First look into LOB markets using \cite{glosten_is_1994}.
		\item Limit traders act in the same capacity as the dealer did before
		\begin{itemize}
			\item but face different informational environment
			\item so act differently
			\item which leads to different market outcomes
		\end{itemize}
	\end{itemize}
\end{frame}


\begin{frame}{Next week}
	\begin{itemize}
		\item Many aspects of market design (tick size, priority rules) are all double-edged swords, swing them carefully
		\item Dynamic analysis: traders can choose between limit and market orders
	\end{itemize}
\end{frame}


\begin{frame}{Exercise for next week}
	\begin{itemize}
		\item Suppose that there is no tick; quotes can  be placed in a continuous price space. Suppose that there is price priority. What is then the role of time priority, so that first-come quotes at identical prices are served first?
		\item If you could choose between trading at discriminatory prices in a limit order book, or to reveal your order size to a dealer, what would influence your choice?
		% ex1 is on informed trading
		% ex5 is on make-or-take choice 
		\item Solve exercise 1 on pages 232-233 (ch.6) in the textbook. Note that you need to use Bayes' rule to assess the conditional distribution over $v$ given a market order of size $q$
		%\item Solve exercise 5 on page 235 in the textbook on the effect of fees charged for limit orders and market orders
	\end{itemize}
\end{frame}





\appendix
\begin{frame}[allowframebreaks]{References}
	\bibliography{../teaching}
	\bibliographystyle{abbrvnat}
\end{frame}




\end{document} 